class Solution:
    def removeSubstring(self, s: str, k: int) -> str:
        if len(s) < k * 2: return s
        t = "(" * k + ")" * k

        for i in range(len(s)-2*k+1):
            if s[i:i + 2 * k] == t:
                return self.removeSubstring(s[:i] + s[i + 2 * k:], k)
        return s


if __name__ == '__main__':
    s = Solution()
    r = s.removeSubstring( s = "(())", k = 1)
    print(r)